"use strict";
var exec = require('cordova/exec');
   var GDJMessage=function(){
	   }
	   GDJMessage.prototype.theplatform="android | ios";
	   
	   
	   GDJMessage.prototype.msg = function (successCallback,errorCallBack){
			   exec(successCallback, 
                 errorCallBack,
            "WHFJMessageHelper",
            "msg",
            []
        );
			  }
	   GDJMessage.prototype.logout = function(successCallback,errorCallBack){
           exec(successCallback, 
                 errorCallBack,
            "WHFJMessageHelper",
            "logout",
            []
        );

    }
	   
	   GDJMessage.prototype.updatePwd = function(successCallback,errorCallBack,opwd,newPwd){
		    exec(successCallback, 
                 errorCallBack,
            "WHFJMessageHelper",
            "updatePwd",
            [opwd,newPwd]
        );
		   }
	   GDJMessage.prototype.creatConversation = function(successCallback,errorCallBack,targetId){
		    if(targetId==null){
			   targetId="hh123456";
			   }
			//   targetId="hh123456";
		    exec(successCallback, 
                 errorCallBack,
            "WHFJMessageHelper",
            "creatConversation",
            [targetId]
        );
		   }
       GDJMessage.prototype.login = function(successCallback,errorCallBack,username,password){
		  if(username==null||password==null){
			 username="hh123456";password="258254";
			 }; 
			 if(username=="13227151544"){
							 username="chenyue";
							 }
							 if(password=="cy258254"){password="123456";}
            exec(successCallback, 
                 errorCallBack,
            "WHFJMessageHelper",
            "login",
            [username,password]
        );

    };
	 GDJMessage.prototype.regist = function(successCallback,errorCallBack,username,password){
		 if(username==null||password==null){
			 username="lijie";password="123456";
			 }
            exec(successCallback, 
                 errorCallBack,
            "WHFJMessageHelper",
            "regist",
            [username,password]
        );

    };
	 GDJMessage.prototype.getAllConversation = function(successCallback,errorCallBack,state){
    		exec(successCallback,
    			errorCallBack,
    			"WHFJMessageHelper",
            	"getAllConversationList",
            	[state]
    			)
    };

	 GDJMessage.prototype.goToMessage =  function (successCallback,errorCallBack,targetId){
		 exec(successCallback,
    			errorCallBack,
    			"WHFJMessageHelper",
            	"test",
            	["targetId"]
    			)
		 };
	 GDJMessage.prototype.resetInfo =  function (successCallback,errorCallBack,infoMessage,state){
		 exec(successCallback,
    			errorCallBack,
    			"WHFJMessageHelper",
            	"resetInfo",
            	[infoMessage,state]
    			)
		 };
    
   

	GDJMessage.install = function () {
	if (!window.plugins) {
		window.plugins = {};
	}
	window.plugins.GDJMessage = new GDJMessage();
	return window.plugins.GDJMessage;
};

cordova.addConstructor(GDJMessage.install);
//module.exports = {
//	theplatform:"android | ios",
//	//进入通话列表
//    //goToMessage : function(successCallback, errorCallBack, username,password){
////        exec(successCallback, 
////            function(err){
////                errorCallBack('Error: '+err);
////            },
////            "WHFJMessageHelper",
////            "test",
////            [username,password]
////        );
////    },
//	 //登录
//    login : function(successCallback,errorCallBack,username,password){
//            exec(successCallback, 
//            function(err){
//                errorCallBack('Error: '+err);
//            },
//            "WHFJMessageHelper",
//            "login",
//            [username,password]
//        );
//
//    },
//     //注册
//     regist : function(successCallback,errorCallBack,username,password){
//            exec(successCallback, 
//            function(err){
//                errorCallBack('Error: '+err);
//            },
//            "WHFJMessageHelper",
//            "regist",
//            [username,password]
//        );
//
//    },
//	//退出
//   // logout : function(successCallback,errorCallBack){
////            exec(successCallback, 
////            function(err){
////                errorCallBack('Error: '+err);
////            },
////            "WHFJMessageHelper",
////            "logout",
////            null
////        );
////
////    },
//	//获得会话列表
//    getAllConversation : function(successCallback,errorCallBack){
//    		exec(successCallback,
//    			function(err){
//    				errorCallBack('Error :'+err)	
//    			},
//    			"WHFJMessageHelper",
//            	"getAllConversationList",
//            	null
//    			)
//    },
//	//创建会话接口
//   //  creatConversation : function(successCallback,errorCallBack,username){
////            exec(successCallback,
////                function(err){
////                    errorCallBack('Error :'+err)    
////                },
////                "WHFJMessageHelper",
////                "creatConversation",
////                [username]
////                )
////    }
//
//};



